package nc.ui.ntb.outer.ref;

import java.util.Hashtable;

import nc.tb.pub.util.NtbLogger;
import nc.ui.ntb.outer.itf.AbstractNtbRefPane;
import nc.ui.ntb.outer.itf.INtbRefClassFactory;

public class NtbRefClassFactory implements INtbRefClassFactory {

	public final static String REF_TYPE_PLANLIST = "ntbRef_Plan";
	public final static String REF_TYPE_PLAN2CELLVALUE = "ntbRef_Plan2CellValue";
	public final static String REF_TYPE_CUBEVIEW = "ntbRef_CubeView";
	
	private static Hashtable<String, String> classMap = new Hashtable<String, String>();
	static {
		classMap.put(REF_TYPE_PLANLIST, "nc.ui.ntb.outer.ref.NtbPlanListRefPane");
		classMap.put(REF_TYPE_PLAN2CELLVALUE, "nc.ui.ntb.outer.ref.NtbPlanCellSelectRefPane");
		classMap.put(REF_TYPE_CUBEVIEW, "nc.ui.ntb.outer.ref.NtbCubeCellSelectRefPane");
	}
	
	public AbstractNtbRefPane getNtbRefNewInstance(String refType) {
		String className = classMap.get(refType);
		if (className != null) {
			try {
				return (AbstractNtbRefPane)Class.forName(className).newInstance();
			} catch (InstantiationException e) {
				NtbLogger.printException(e);
			} catch (IllegalAccessException e) {
				NtbLogger.printException(e);
			} catch (ClassNotFoundException e) {
				NtbLogger.printException(e);
			}
		}
		return null;
	}
}
